package com.example.schooljava.controller;


import com.example.schooljava.annotation.RequestLimit;
import com.example.schooljava.pojo.entity.UserRole;
import com.example.schooljava.service.impl.UserRoleServiceImpl;
import com.example.schooljava.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LDH
 * @since 2022/08/13
 */
@RestController
@RequestMapping("/school/user-role")
@RequestLimit(maxCount = 5,second = 2)
@Api(tags = "用户角色关系模块")
public class UserRoleController {

    @Autowired
    private UserRoleServiceImpl userRoleService;

    @ApiOperation(value = "添加用户身份",notes = "<span style='color:red;'>详细描述：</span>&nbsp;管理员设置用户身份")
    @PostMapping(name = "系统管理员,校长")
    public Result setUserRole(UserRole userRole){
        return userRoleService.setUserRole(userRole);
    }

    @ApiOperation(value = "删除用户身份关系",notes = "<span style='color:red;'>详细描述：</span>&nbsp;管理员删除用户身份关系")
    @DeleteMapping(name = "系统管理员,校长")
    public Result delUserRole(ArrayList<String> list){
        return userRoleService.delUserRole(list);
    }

}
